﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Xml.Linq;
using RCSP.DataAccess;
using RCSP.FrontEnd;

namespace RCSP.FrontEnd
{
    public class Global : System.Web.HttpApplication
    {
        public static string APP_PATH;
        protected void Application_Start(object sender, EventArgs e)
        {
            InitConnectionToDB();
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (Request.ApplicationPath != "/")
            {
                APP_PATH = Request.ApplicationPath;
            }
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }

        private void InitConnectionToDB()
        {
            //load the connection string in Web.config which is used to access the RCSP database.
            string connectionString = ConfigurationManager.AppSettings["RCSPConnectionString"];
            RCSPConnectionManager.CreateConnectionManager(connectionString);
            RCSPAppManager.SetObject(ApplicationVars.CONNECTION_STRING, connectionString);
        }
    }


}